import { Component, OnInit, ViewChild, Input, Output, EventEmitter } from '@angular/core';
import { HttpService, SupDic, GridComponent } from 'lbf';
import { SFComponent, SFSchema, SFRadioWidgetSchema } from '@delon/form';
import { STColumn } from '@delon/abc';
import { NzMessageService } from 'ng-zorro-antd';
import { delay } from 'rxjs/operators';
import { of } from 'rxjs';
import { BussFormComponent } from '../buss_form/buss_form.component';


@Component({
  selector: 'lb-form',
  templateUrl: './lb_form.html',
})
export class LbFormComponent implements OnInit {
  jyshow = false;
  errcolumns:STColumn[] = [
    { title: '事项名称', index: 'DAD031'},
    { title: '校验结果', index: 'ERRMSG'},
  ];
  sbxxSchema: SFSchema = {
    properties: {
      DAD071: {
        type: 'string',
        title: '',
        // tslint:disable-next-line: no-object-literal-type-assertion
        ui: {
          widget: 'radio',
          asyncData: () =>
            of([
              { label: '当事人', value: '1' },
              { label: '代办人', value: '0' },
            ]).pipe(delay(100)),
          change: console.log,
          grid: {
            span: 24,
          },
        } as SFRadioWidgetSchema,
        default: '1',
      },
      DAD074: {
        type: 'string',
        title: '证件类型',
        enum: this.supDic.getSFDic('DAD074'),
        ui: {
          widget: 'select',
        },
        default: '0',
      },
      DAD070: { type: 'string', title: '申报人证件号码' },
      DAD075: { type: 'string', title: '申报人名称' },

      DAD116: {
        type: 'string',
        title: '证件类型',
        enum: this.supDic.getSFDic('DAD074'),
        ui: {
          widget: 'select',visibleIf: { DAD071: ['0'] }
        },
        default: '0',
      },
      DAD114: { type: 'string', title: '申请人证件号码',ui: { visibleIf: { DAD071: ['0'] } } },
      DAD113: { type: 'string', title: '申请人名称' ,ui: { visibleIf: { DAD071: ['0'] } }},
      DAD115: { type: 'string', title: '联系电话' },

      DAD065: {
        type: 'string',
        title: '',
        enum: [
          { label: '自取', value: '1' },
          { label: '邮寄', value: '2' },
          { label: '短信', value: '3' },
          { label: '无需送达', value: '9' },
        ],
        // tslint:disable-next-line: no-object-literal-type-assertion
        ui: {
          widget: 'radio',
          // asyncData: () => of().pipe(delay(100)),
          change: console.log,
          grid: {
            span: 24,
          },
        } as SFRadioWidgetSchema,
        default: '1',
      },
      DAD127: {
        type: 'string',
        title: '送达联系人',
        ui: { visibleIf: { DAD065: ['2'] } },
      },
      DAD132: {
        type: 'string',
        title: '送达联系人电话',
        ui: { visibleIf: { DAD065: ['2'] } },
      },
      DAD119: {
        type: 'string',
        title: '送达地址',
        ui: { visibleIf: { DAD065: ['2'] } },
      },
    },
    ui: {
      spanLabelFixed: 100,
      grid: {
        span: 8,
      },
    },
    required: [
      'DAD074',
      'DAD070',
      'DAD075',
      'DAD114',
      'DAD113',
      'DAD115',
      'DAD116',
    ],
  };
  errparas :any;
  @ViewChild('sbxx', { static: false }) sf1: SFComponent;
  @ViewChild('errst', { static: false }) st: GridComponent;
  @ViewChild('bf', { static: false }) bf: BussFormComponent;

  @Input() set formData(value:any) {
    this.sf1.setValue('/DAD070',value.AAC002)
    this.sf1.setValue('/DAD075',value.AAC003)
    this.sf1.setValue('/DAD114',value.AAC002)
    this.sf1.setValue('/DAD113',value.AAC003)
    this.sf1.setValue('/DAD115',value.EAE033)
    console.log(value)
  }
  get formData(){
    return this.sf1.value;
  }
  formdata: {};
  @Input() set bfForm(value:any) {
    this.bfform = value
  }
  get bfForm(){
    return this.bf.value;
  }
  bfform: {};
  @Input() set DAD069(value:number) {
    this._dad069 = value
    this.bf.DAD069 = this._dad069
  }
  get DAD069(){
    return this._dad069;
  }
  _dad069 = 0

    
  constructor(
    private lbservice: HttpService,
    private supDic: SupDic,
    public msgSrv: NzMessageService,
  ) {
    
  }

  ngOnInit() {
    
  }


}